TAB Function Action Moves the text cursor to a specified print position when used in the PRINT, PRINT USING, LPRINT, LPRINT USING, and PRINT # statements. Syntax ---------------------------------------------------------------------------- TAB( column%) Remarks The argument column% is a numeric expression that is the column number of the new print position. The leftmost print position is always 1. The rightmost position is the current line width of the output device (which can be set with the WIDTH statement). This is an example of using TAB in the PRINT function. PRINT TAB(10); City$; TAB(40); State$; TAB(45); Zip$ The behavior of TAB depends on the relationship between three values. column%, the current print position on the current output line when the TAB function is executed, and the current output-line width. - If the current print position on the current line is greater than column%, TAB skips to column% on the next output line. - If column% is less than 1, TAB moves the print position to column 1. - If column% is greater than the output-line width, TAB calculates. - print position = column% MOD width. - n If the calculated print position is less than the current print position, the cursor jumps to the next line at the calculated print position. If the calculated print position is greater than the current print position, the cursor moves to the calculated print position on the same line. See Also LPRINT, PRINT, SPACE$, SPC Example In the following example TAB is also used with the PRINT statement to center a text string on an 80-column screen. CLS INPUT "What is your full name "; Name$ PRINT ' Get the length of Name$, divide by 2, and subtract from screen ' center point. PRINT TAB(40 - (LEN(Name$) \ 2)); Name$ END